package com.kartoshka.painters 
{
	import flash.display.Graphics;

	import com.kartoshka.painters.NullPainter;

	/**
	 * @author Alexander Zats, 2009
	 */
	public class BackgroundSolidPainter extends NullPainter 
	{

		private var _color : uint;
		private var _alpha : Number;

		public function BackgroundSolidPainter( color : uint = 0xFFFFFF, alpha : Number = 1 )
		{
			this.color = color;
			this.alpha = alpha;
		}

		override public function draw(graphics : Graphics, width : Number, height : Number) : void
		{
			graphics.beginFill( _color, _alpha );
			cornerRadius ? graphics.drawRoundRect( 0, 0, width, height, cornerRadius, cornerRadius ) : graphics.drawRect( 0, 0, width, height );
			graphics.endFill();
		}

		public function set color( value : uint ) : void
		{
			if ( value == _color ) return;
			if ( value > 0xFFFFFF ) _color = 0xFFFFFF;
			else _color = value;
		}

		public function get color() : uint
		{
			return _color;
		}
		
		public function set alpha( value : Number ) : void
		{
			if ( value == _alpha ) return;
			if ( value > 1 ) _alpha = 1;
			else if ( value < 0 ) _alpha = 0;
			else _alpha = value;
		}
		
		public function get alpha() : Number
		{
			return _alpha;
		}
	}
}